﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CarCrash.Application.Drawing.entities.Forms
{

    public partial class LineForm : Form
    {

        private Line line;

        public LineForm(Line line)
        {
            InitializeComponent();
            this.line = line;
            colorDialog.Color = line.Color;
            line.Color = colorDialog.Color;
            colorPanel.BackColor = colorDialog.Color;
            thicknessTextBox.Text = line.Thickness.ToString();
        }

        private void colorButton_Click(object sender, EventArgs e)
        {
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                line.Color = colorDialog.Color;
                colorPanel.BackColor = line.Color;
            }
        }

        private void thicknessTextBox_TextChanged(object sender, EventArgs e)
        {
            int thickness;
            if (Int32.TryParse(thicknessTextBox.Text, out thickness))
                line.Thickness = thickness;
        }

        private void Submit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }

}